package com.ynkbny.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ynkbny.base.PageResult;
import com.ynkbny.domain.DeviceHistoryData;
import com.ynkbny.domain.mongo.DeviceHistoryDataMon;
import com.ynkbny.domain.mongo.DeviceHistoryDataVO;
import com.ynkbny.mapper.DeviceHistoryDataMapper;
import com.ynkbny.service.DeviceHistoryDataService;
import com.ynkbny.util.MongoUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


/**
 * 属性的历史数据-表服务实现类
 *
 * @author : juzipi123
 * @date : 2023-7-26
 */
@Slf4j
@Service
public class DeviceHistoryDataServiceImpl extends ServiceImpl<DeviceHistoryDataMapper, DeviceHistoryData> implements DeviceHistoryDataService {

    @Resource
    private MongoUtil mongoUtil;

    /**
     * 根据条件分页 查询
     *
     * @author : juzipi123
     * @param vo 筛选条件
     * @return 查询结果
     */
    @Override
    public PageResult<DeviceHistoryDataMon> paginQuery(DeviceHistoryDataVO vo) {
        log.info("入参：{}",vo);
        long count = mongoUtil.count(vo, DeviceHistoryDataMon.class, "deviceHistoryData");
        log.info("返回总条数：{}",count);
        List<DeviceHistoryDataMon> list = mongoUtil.paginQuery(vo, DeviceHistoryDataMon.class, "deviceHistoryData");
        log.info("返回具体信息：{}",list);
        PageResult<DeviceHistoryDataMon> result = new PageResult<>(list, count, vo.getPageNum(), vo.getPageSize());
        log.info("方法返回值：{}",result);
        return result;
    }
}